//
//  SXTMyMessageHeadView.m
//  SXT
//
//  Created by 赵金鹏 on 16/8/11.
//  Copyright © 2016年 赵金鹏. All rights reserved.
//

#import "SXTMyMessageHeadView.h"

@interface SXTMyMessageHeadView()
@property (strong, nonatomic)   UIImageView *headBackImage;        /**headView的背景图片*/
@property (strong, nonatomic)   UIButton *loginBtn;              /** 登录button */
@property (strong, nonatomic)   UIButton *landingBtn;              /** 注册button */
@end

@implementation SXTMyMessageHeadView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubview:self.headBackImage];
        [self addSubview:self.loginBtn];
        [self addSubview:self.landingBtn];
    }
    return self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    __weak typeof (self) weakSelf = self;
    
    [_headBackImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(weakSelf);
    }];
    
    [_loginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(weakSelf.mas_centerX).offset(60);
        make.centerY.equalTo(weakSelf.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(45, 23));
    }];
    
    [_landingBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(weakSelf.mas_centerX).offset(-60);
        make.centerY.equalTo(weakSelf.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(45, 23));
    }];
}

- (UIImageView *)headBackImage{
    if (!_headBackImage) {
        _headBackImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"我的背景"]];
    }
    return _headBackImage;
}

- (UIButton *)loginBtn{
    if (!_loginBtn) {
        _loginBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
        [_loginBtn setTitle:@"登录" forState:(UIControlStateNormal)];
        _loginBtn.titleLabel.font = [UIFont systemFontOfSize:18.0f];
        _loginBtn.titleLabel.textColor = [UIColor whiteColor];
        [_loginBtn addTarget:self action:@selector(loginBtnMethod) forControlEvents:(UIControlEventTouchUpInside)];
    }
    return _loginBtn;
}

- (UIButton *)landingBtn{
    if (!_landingBtn) {
        _landingBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
        [_landingBtn setTitle:@"注册" forState:(UIControlStateNormal)];
        _landingBtn.titleLabel.font = [UIFont systemFontOfSize:18.0f];
        _landingBtn.titleLabel.textColor = [UIColor whiteColor];
        [_landingBtn addTarget:self action:@selector(landingBtnMethod) forControlEvents:(UIControlEventTouchUpInside)];
    }
    return _landingBtn;
}
//登录按钮点击方法
- (void)loginBtnMethod{
    if (_loginBtnBlock) {
        _loginBtnBlock();
    }
}
//注册按钮点击方法
- (void)landingBtnMethod{
    if (_landingBlock) {
        _landingBlock();
    }
}

@end
